package com.douqu.game.core.entity.sprite;

import com.douqu.game.core.entity.GameObject;
import com.douqu.game.core.factory.DataFactory;
import com.douqu.game.core.util.LoadUtils;

/**
 * Created by bean on 2017/8/14.
 */
public class SoldierRestrict extends GameObject {

    /**
     * 克制的类型列表
     */
    public int[] restricts;


    /**
     * 是否被克制
     * @param types
     * @return
     */
    public boolean isRestrict(SoldierRestrict[] types)
    {
        for(int type : restricts)
        {
            for(SoldierRestrict checkValue : types)
            {
                if(type == checkValue.getId())
                    return true;
            }
        }
        return false;
    }



    @Override
    public void setVariable(String key, String value)
    {
        if("restricts".equals(key))
        {
            restricts = LoadUtils.loadIntArray(key, value);
        }
        else
            super.setVariable(key, value);
    }



}
